package com.rivulet.doj_backend.depend;

import org.apache.commons.lang3.ArrayUtils;

import java.util.Arrays;

public class ServiceException extends ApplicationException {
    private Status status;
    private Object[] args;

    public ServiceException(String msg) {
        super(msg);
        this.args = ArrayUtils.EMPTY_OBJECT_ARRAY;
    }

    public ServiceException(String msg, Throwable cause) {
        super(msg, cause);
        this.args = ArrayUtils.EMPTY_OBJECT_ARRAY;
    }

    public ServiceException(Status status) {
        this(status.toString());
        this.status = status;
    }

    public ServiceException(Status status, Object... args) {
        this(status.toString() + ", args: " + Arrays.toString(args));
        this.status = status;
        this.args = args;
    }

    public ServiceException(Status status, Throwable cause) {
        this(status.toString(), cause);
        this.status = status;
    }

    public ServiceException(Status status, String message) {
        this(status.toString() + ", " + message);
        this.status = status;
    }

    public Status getStatus() {
        return this.status;
    }

    public Object[] getArgs() {
        return this.args;
    }
}
